import {get, post, del, put} from "@/apis/http/request";
import { Permit } from "../../model/system/PermitModel";
import { RolePermit } from "../../model/system/RoleModel";

/**
 * 得到菜单列表
 * @param params
 */
export const getPermitList = (params: any) => get("/permit/list", params)

/**
 * 得到菜单分页列表
 * @param params
 */
export const permitPage = (params: any) => post("/permit/page", params)

/**
 * 循环获取权限
 * @returns 
 */
export const permitLoop = (params: any) => post("/permit/loopList",params)

/**
 * 删除数据
 * @param id 
 * @returns 
 */
export const deletePermitById = (id: number) => del("/permit/delete/"+ id)

/**
 * 新增数据
 * @param param
 */
export const insertPermit = (param: Permit) => post("/permit", param)

/**
 * 更新数据
 * @param param
 */
export const updatePermit = (param: Permit) => put("/permit", param)

/**
 * 
 * @param id 根据角色role查询权限
 * @returns 
 */
export const listPermitIdByRoleId = (roleId: number) => get("/permit/listPermitIdByRoleId/" + roleId);

/**
 * 根据菜单编号得到菜单赋予的权限
 * @param menuId
 */
export const listPermitIdByMenuId = (menuId: number) => get("/permit/listPermitIdByMenuId/" + menuId);

export const savePermitByRoleId = (rolePermit: RolePermit ) => post("/permit/savePermitByRoleId", rolePermit)

export const savePermitByMenuId = (rolePermit: RolePermit ) => post("/permit/savePermitByMenuId", rolePermit)